﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {

        }
        int n = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            //for (int i = 0; i < userControl11.lstInt.Count; i++)
            //{
            //    userControl11.lstInt[i] = userControl11.lstInt[i] + n;
            //}
            //n++;
            //userControl11.Invalidate();
        }
        private ModuleParam CreateModel(string modelName, string modelRemarks, string windowName, double costTime,string path)
        {
            ModuleParam moduleParam = new ModuleParam();
            moduleParam.PluginName = modelName;
            moduleParam.ModuleName = modelName;
            moduleParam.ModuleRemarks = modelRemarks;
            moduleParam.WindowName = windowName;
            moduleParam.CostTime = costTime;
            Icon icon = new Icon(path);
            moduleParam.Icon=icon;
            return moduleParam;
        }
        private void Add(ModuleParam moduleParam)
        {
            userControl11.mProj.AddModObj("", moduleParam, true);
        }
        private void Add(string parentName, ModuleParam moduleParam)
        {
            userControl11.mProj.AddModObj(parentName, moduleParam, true);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string tag = (sender as Button).Tag.ToString();
            int index= int.Parse(tag)-1;
            if (0 == index)
            {
                for (int i = 0; i < 1; i++)
                {
                    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\Blob.ico");
                    ModuleParam moduleParam = CreateModel("全局变量模块", "", "win3", 0.1, path);
                    Add(moduleParam);
                }
    
            }
            else if (1 == index)
            {
                string path= ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\脚本代码.ico");
                ModuleParam moduleParam = CreateModel("Csharp脚本", "", "win3", 101.9, path);
                Add(moduleParam);
            }
            else if (2 == index)
            {
                string path= ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\相机采集.ico");
                ModuleParam moduleParam = CreateModel("相机图像", "", "win3", 101.7, path);
                Add(moduleParam);
            }
            else if (3 == index)
            {
                string path= ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\像素标定.ico");
                ModuleParam moduleParam = CreateModel("像素标定", "", "win3", 0.0, path);
                Add(moduleParam);
            }
            else if (4 == index)
            {
                string path= ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\rgb模式.ico");
                ModuleParam moduleParam = CreateModel("彩色转RGB", "", "win3", 0.2, path);
                Add(moduleParam);
            }
            else if (5 == index)
            {
                string path= ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\图像处理.ico");
                ModuleParam moduleParam = CreateModel("图像预处理", "", "win3", 91.5, path);
                Add(moduleParam);
            }
            else if (6 == index)
            {
                string path= ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\图像采集.ico");
                ModuleParam moduleParam = CreateModel("显示图像", "", "win3", 4.3, path);
                Add(moduleParam);
            }
            else if (7 == index)
            {
                string path= ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\模型匹配.ico");
                ModuleParam moduleParam = CreateModel("模板匹配", "", "win3", 4.3, path);
                Add(moduleParam);
            }
            else if (8 == index)
            {
                string path= ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\亮度.ico");
                ModuleParam moduleParam = CreateModel("亮度检测", "", "win3", 4.9, path);
                Add(moduleParam);
            }
            else if (9 == index)
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\if.ico");
                ModuleParam moduleParam = CreateModel("如果", "", "win3", 0.1, path);
                Add(moduleParam);
            }
            else if (10 == index)
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\坐标系.ico");
                ModuleParam moduleParam = CreateModel("坐标补正", "", "win3", 0.1, path);
                Add(moduleParam);
            }
            else if (11 == index)
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\文件夹1.ico");
                ModuleParam moduleParam = CreateModel("文件夹", "", "win3", 0.1, path);
                Add(moduleParam);
            }
            userControl11.ChangeEvents(null, null);
            userControl11.Refresh();
        }

        private void CreateIf()
        {
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\Blob.ico");
            //    ModuleParam moduleParam = CreateModel("全局变量模块", "", "win3", 0.1, path);
            //    Add(moduleParam);
            //}
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\if.ico");
                ModuleParam moduleParam = CreateModel("如果", "", "win3", 0.1, path);
                Add(moduleParam);
            }
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\图像处理.ico");
                ModuleParam moduleParam = CreateModel("图像预处理", "", "win3", 91.5, path);
                Add("如果0", moduleParam);
            }
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\图像处理.ico");
                ModuleParam moduleParam = CreateModel("图像预处理", "", "win3", 91.5, path);
                Add("如果0", moduleParam);
            }
        }
        private void CreateFolder()
        {
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\坐标系.ico");
                ModuleParam moduleParam = CreateModel("坐标补正", "", "win3", 0.1, path);
                Add(moduleParam);
            }
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\图像处理.ico");
                ModuleParam moduleParam = CreateModel("图像预处理", "", "win3", 91.5, path);
                Add("坐标补正0", moduleParam);
            }
        }
        private void CreatePixFix()
        {
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\文件夹1.ico");
                ModuleParam moduleParam = CreateModel("文件夹", "", "win3", 0.1, path);
                Add(moduleParam);
            }
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\文件夹1.ico");
                ModuleParam moduleParam = CreateModel("文件夹", "", "win3", 0.1, path);
                Add("文件夹0", moduleParam);
            }
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\图像处理.ico");
                ModuleParam moduleParam = CreateModel("图像预处理", "", "win3", 91.5, path);
                Add("文件夹1", moduleParam);
            }
        }
        private void button10_Click(object sender, EventArgs e)
        {
            //CreateIf();
            //CreateFolder();
            //CreatePixFix();
            //userControl11.ChangeEvents(null, null);
            //userControl11.Refresh();
            //return;
            //for (int i = 0; i < 1; i++)
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\var.ico");
            //    ModuleParam moduleParam = CreateModel("全局变量模块", "", "win3", 0.1, path);
            //    Add(moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\脚本代码.ico");
            //    ModuleParam moduleParam = CreateModel("Csharp脚本", "", "win3", 101.9, path);
            //    Add(moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\相机采集.ico");
            //    ModuleParam moduleParam = CreateModel("相机图像", "", "win3", 101.7, path);
            //    Add(moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\脚本代码.ico");
            //    ModuleParam moduleParam = CreateModel("Csharp脚本", "", "win3", 101.9, path);
            //    Add(moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\像素标定.ico");
            //    ModuleParam moduleParam = CreateModel("像素标定", "", "win3", 0.0, path);
            //    Add(moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\rgb模式.ico");
            //    ModuleParam moduleParam = CreateModel("彩色转RGB", "", "win3", 0.2, path);
            //    Add(moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\图像处理.ico");
            //    ModuleParam moduleParam = CreateModel("图像预处理", "", "win3", 91.5, path);
            //    Add(moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\图像采集.ico");
            //    ModuleParam moduleParam = CreateModel("显示图像", "", "win3", 4.3, path);
            //    Add(moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\模型匹配.ico");
            //    ModuleParam moduleParam = CreateModel("模板匹配", "", "win3", 4.3, path);
            //    Add(moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\亮度.ico");
            //    ModuleParam moduleParam = CreateModel("亮度检测", "", "win3", 4.9, path);
            //    Add(moduleParam);
            //}
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\if.ico");
                ModuleParam moduleParam = CreateModel("如果", "", "win3", 0.1, path);
                Add(moduleParam);
            }
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\坐标系.ico");
                ModuleParam moduleParam = CreateModel("坐标补正", "", "win3", 0.1, path);
                Add("如果0", moduleParam);
            }
            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\文件夹1.ico");
                ModuleParam moduleParam = CreateModel("文件夹", "", "win3", 0.1, path);
                Add("坐标补正0", moduleParam);
            }

            {
                string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\直线.ico");
                ModuleParam moduleParam = CreateModel("找直线中心", "", "win3", 4.9, path);
                Add("文件夹0",moduleParam);
            }
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\拟合线.ico");
            //    ModuleParam moduleParam = CreateModel("直线测量", "", "win3", 4.9, path);
            //    Add("文件夹0", moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\Blob.ico");
            //    ModuleParam moduleParam = CreateModel("Blob分析", "", "win3", 4.9, path);
            //    Add("文件夹0", moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\拐点.ico");
            //    ModuleParam moduleParam = CreateModel("区域间距测量", "", "win3", 4.9, path);
            //    Add("文件夹0", moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\点到线距离.ico");
            //    ModuleParam moduleParam = CreateModel("点线测量", "", "win3", 4.9, path);
            //    Add("文件夹0", moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\点到线距离.ico");
            //    ModuleParam moduleParam = CreateModel("点线测量", "", "win3", 4.9, path);
            //    Add("文件夹0", moduleParam);
            //}
            //{
            //    string path = ("E:\\ai lfy\\TreeExHZL\\WindowsFormsApp1\\Resource\\判断.ico");
            //    ModuleParam moduleParam = CreateModel("数据判断显示", "", "win3", 4.9, path);
            //    Add("文件夹0", moduleParam);
            //}
            userControl11.ChangeEvents(null, null);
            userControl11.Refresh();
        }

        private void button12_Click(object sender, EventArgs e)
        {
            userControl11.changeScore();
        }
    }
}
